<cpanel include="../../config.php">

<?

/***************************************************************************
 *                                 backup.php
 *                            -------------------
 *   Begin                : Thursday, April 16, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.0.0
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$html_root_path = '../../';
$page_title = "Backup";
include $root_path.'common.php';
include $root_path.'page_header.php';

$template->set_filenames(array(
	'body' => $root_path.$template_path.'files/backup.tpl')
);

// This variable seems to just dump out an error message on some systems, and do nothing on others. I'll do something with it at some point...
$random_variable = <<<EOFpacman
<cpanel CpBackup="listbackups()">
EOFpacman;


// The upload bits seem to need the home directory passed to them. This is bad...
$home_directory = <<<EOFpacman
<cpanel print="$homedir">
EOFpacman;

// The link to the latest home backup, seemingly generated by cpanel automagically.
$home_backup_latest = <<<EOFpacman
<cpanel Cgi="backuplink()">
EOFpacman;

$home_backups = <<<EOFpacman
<cpanel Fileman="listfullbackups()">
EOFpacman;

$mysql_database_backups_with_junk = <<<EOFpacman
<cpanel Mysql="listdbsbackup()">
EOFpacman;

$mysql_database_backups_with_junk = explode("\n", $mysql_database_backups_with_junk);

$array_of_mysql_database_backups = array();
$i=0;

foreach($mysql_database_backups_with_junk as $row) {
	$temp = explode('<a href="', $row);
	$temp2 = explode('">', $temp[1]);
	$array_of_mysql_database_backups[$i]['url'] = $temp2[0];
	
	$temp3 = explode('</a>', $temp2[1]);
	$array_of_mysql_database_backups[$i]['name'] = $temp3[0];

	$i++;
};

foreach ($array_of_mysql_database_backups as $row) {

	if (!empty($row['url'])) {
		$template->assign_block_vars('database_backups_row', array(
			'URL' => $row['url'],
			'NAME' => $row['name'],
			)
		);
	}

}

$alias_backups_with_junk = <<<EOFpacman
<cpanel Email="listaliasbackups()">
EOFpacman;

$alias_backups_with_junk = explode("<br>", $alias_backups_with_junk);
$array_of_alias_backups = array();
$i=0;

foreach($alias_backups_with_junk as $row) {
	$temp = explode('<a href="', $row);
	$temp2 = explode('">', $temp[1]);
	$array_of_alias_backups[$i]['url'] = $temp2[0];
	
	$temp3 = explode('</a>', $temp2[1]);
	$array_of_alias_backups[$i]['name'] = $temp3[0];

	$i++;
};

foreach ($array_of_alias_backups as $row) {

	if (!empty($row['url'])) {
		$template->assign_block_vars('alias_backups_row', array(
			'URL' => $row['url'],
			'NAME' => $row['name'],
			)
		);
	}

}


$filter_backups_with_junk = <<<EOFpacman
<cpanel Email="listfilterbackups()">
EOFpacman;

$filter_backups_with_junk = explode("<br>", $filter_backups_with_junk);
$array_of_filter_backups = array();
$i=0;

foreach($filter_backups_with_junk as $row) {
	$temp = explode('<a href="', $row);
	$temp2 = explode('">', $temp[1]);
	$array_of_filter_backups[$i]['url'] = $temp2[0];
	
	$temp3 = explode('</a>', $temp2[1]);
	$array_of_filter_backups[$i]['name'] = $temp3[0];

	$i++;
};

foreach ($array_of_filter_backups as $row) {

	if (!empty($row['url'])) {
		$template->assign_block_vars('filter_backups_row', array(
			'URL' => $row['url'],
			'NAME' => $row['name'],
			)
		);
	}

}

$current_email = <<<EOFpacman
<cpanel CustInfo="getemail()">
EOFpacman;

$template->assign_vars(array(
	'TEMP_LIST_OF_HOME_BACKUPS' => $home_backups,
	'HOME_DIRECTORY' => $home_directory,
	'U_LATEST_HOME_BACKUP' => $home_backup_latest,
	'S_BACKUP_ACTION' => 'backup_full_done.php',
	'S_UPLOAD_HOME_ACTION' => 'backup_upload_home_done.php',
	'S_UPLOAD_DATABASE_ACTION' => 'backup_upload_database_done.php',
	'S_UPLOAD_ALIAS_FILTER' => 'backup_upload_alias_filter_done.php',
	'EMAIL_ADDRESS' => $current_email,
	)
);



//
// Woohoo! All done!
//
$template->pparse('body');




include $root_path.'page_tail.php';




?>